import { createSlice } from '@reduxjs/toolkit'
import type { MenuState } from '../interface'

const initialState: MenuState = {
  isCollapse: false,
  menuList: [],
}

const menu = createSlice({
  name:'menu',
  initialState,
  reducers: {
    // 切换菜单栏
    updateCollapse(state, action) {
      state.isCollapse = action.payload
    },
    // 设置菜单列表
    setMenuList(state, action) {
      state.menuList = action.payload
    }
  }
})

const { updateCollapse, setMenuList } = menu.actions

export default menu.reducer
export { updateCollapse, setMenuList }